package com.grudesign.stutrip.controller;


import com.grudesign.stutrip.common.ReturnInfo;
import com.grudesign.stutrip.entity.Po.BasecampPo;
import com.grudesign.stutrip.entity.Vo.newsQueryVo;
import com.grudesign.stutrip.service.BasecampService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 基地营地表 前端控制器
 * </p>
 *
 * @author wx
 * @since 2022-05-09
 */
@RestController
@RequestMapping("/basecamp")
public class BasecampController {
    
    @Autowired
    private BasecampService basecampService;


    @PostMapping("/getBases/{cur}/{li}")
    public Object getQueryBase(@PathVariable String cur,
                               @PathVariable String li){
        Object obj =  basecampService.getBases(cur,li);
        return obj;
    }
    @PostMapping("/getBaseLs/{cur}/{li}")
    public Object getQueryB(@PathVariable long cur,
                               @PathVariable long li,
                               @RequestBody(required = false) BasecampPo po){
        Object obj =  basecampService.getBases(cur,li,po);
        return obj;
    }
    @PostMapping("/addBaseCamp")
    public Object addBase(@RequestBody BasecampPo basecampPo){
        boolean save = basecampService.save(basecampPo);
        return save?new ReturnInfo("200","ok"):new ReturnInfo("-1","err");
    }

    @PutMapping("/editBase")
    public Object editBase(@RequestBody BasecampPo BasecampPo){
        boolean edit = basecampService.updateById(BasecampPo);
        return edit?new ReturnInfo("200","ok"):new ReturnInfo("-1","err");
    }
    @DeleteMapping("/{id}")
    public  Object delBase(@PathVariable String id){
        boolean isDel = basecampService.removeById(id);
        return isDel?new ReturnInfo("200","ok"):new ReturnInfo("-1","err");
    }
}

